package com.zhiyou100.lan;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import com.zhiyou100.entity.prosGo.TbUser;

public class Lanlan implements HandlerInterceptor {

	private static String[] PASS_GO= {"index.do","regist.do","ly-list.do","gyzc-list.do","login.do" }; 
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
			throws Exception {
		System.out.println(request.getRequestURI());
		for(int i =0;i<PASS_GO.length;i++) {
			if (request.getRequestURI().endsWith(PASS_GO[i])) {
				return true;
			}
		}
		TbUser user =(TbUser)request.getAttribute("tbUser2");
		if (user==null) {
			System.out.println("拦截了");
			request.getRequestDispatcher("WEB-INF/login.jsp").forward(request, response);
			return false;
		}
		return true;
	}

	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler,
			ModelAndView modelAndView) throws Exception {
	
	}

	public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
			throws Exception {
	
	}
}
